from common.model.milvus_utils import MilvusConf
from pydantic import BaseModel, ConfigDict, Field
from pydantic_settings import BaseSettings

from common.rpc import stub
from common.utils import logger, tracing

class AliEmbeddingsConf(BaseModel):
    api_key: str = Field(alias="ApiKey")
    model: str = Field(alias="Model")

class AliLlmConf(BaseModel):
    base_url: str = Field(alias="BaseUrl")
    api_key: str = Field(alias="ApiKey")
    model: str = Field(alias="Model")

class Config(BaseSettings):
    model_config = ConfigDict(extra="ignore")
    
    name: str = Field(alias="Name")
    listen_on: str = Field(alias="ListenOn")
    max_workers: int = Field(alias="MaxWorkers", default=10)
    
    log: logger.LogConf = Field(alias="Log")
    telemetry_conf: tracing.TelemetryConf = Field(alias="Telemetry")
    
    milvus_conf: MilvusConf = Field(alias="MilvusConf")
    
    ali_embeddings_conf: AliEmbeddingsConf = Field(alias="AliEmbeddingsConf")
    ali_llm_conf: AliLlmConf = Field(alias="AliLlmConf")
    
    assistant_rpc_conf: stub.RpcStubConfig = Field(alias="AssistantRpcConf")
    chat_rpc_conf: stub.RpcStubConfig = Field(alias="ChatRpcConf")
    paperfile_rpc_conf: stub.RpcStubConfig = Field(alias="PaperfileRpcConf")